# Maintainer: Jenneron <jenneron@protonmail.com>
pkgname=moonlight-qt
pkgver=5.0.1
pkgrel=1
pkgdesc="Open Source PC client for NVIDIA GameStream, as used by the NVIDIA Shield"
url="https://moonlight-stream.org/"
# riscv64 blocked by libdav1d
arch="all !riscv64"
license="GPL-3.0-or-later"
depends="ffmpeg"
makedepends="openssl-dev sdl2-dev sdl2_ttf-dev ffmpeg-dev qt6-qtsvg-dev qt6-qtdeclarative-dev libva-dev libvdpau-dev opus-dev pulseaudio-dev alsa-lib-dev"
_h264bitstream_commit="34f3c58afa3c47b6cf0a49308a68cbf89c5e0bff"
_moonlight_common_c_commit="5de4a5b85a28d8d639482a1a105c3a06eb67a2fd"
_enet_commit="bbfe93c248ce198246328d52bda5b4e6dd4cc95e"
_qmdnsengine_commit="b7a5a9f225d5e14b39f9fd1f905c4f505cf2ee99"
_libsoundio_commit="34bbab80bd4034ba5080921b6ba6d61314126310"
_sdl_gamecontrollerdb_commit="dbcf31a6709ec8354b5963b1bb411721e07bd846"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/moonlight-stream/moonlight-qt/archive/refs/tags/v$pkgver.tar.gz
	h264bitstream-$_h264bitstream_commit.tar.gz::https://github.com/aizvorski/h264bitstream/archive/$_h264bitstream_commit.tar.gz
	moonlight-common-c-$_moonlight_common_c_commit.tar.gz::https://github.com/moonlight-stream/moonlight-common-c/archive/$_moonlight_common_c_commit.tar.gz
	enet-$_enet_commit.tar.gz::https://github.com/cgutman/enet/archive/$_enet_commit.tar.gz
	qmdnsengine-$_qmdnsengine_commit.tar.gz::https://github.com/cgutman/qmdnsengine/archive/$_qmdnsengine_commit.tar.gz
	libsoundio-$_libsoundio_commit.tar.gz::https://github.com/cgutman/libsoundio/archive/$_libsoundio_commit.tar.gz
	sdl-gamecontrollerdb-$_sdl_gamecontrollerdb_commit.tar.gz::https://github.com/gabomdq/SDL_GameControllerDB/archive/$_sdl_gamecontrollerdb_commit.tar.gz
	0001-Fix-building-with-directfb.patch
	"
options="!check" # no tests in upstream

prepare() {
	cp -r "$srcdir/h264bitstream-$_h264bitstream_commit" \
		-T h264bitstream/h264bitstream
	cp -r "$srcdir/moonlight-common-c-$_moonlight_common_c_commit" \
		-T moonlight-common-c/moonlight-common-c
	cp -r "$srcdir/enet-$_enet_commit" \
		-T moonlight-common-c/moonlight-common-c/enet
	cp -r "$srcdir/qmdnsengine-$_qmdnsengine_commit" \
		-T qmdnsengine/qmdnsengine
	cp -r "$srcdir/libsoundio-$_libsoundio_commit" \
		-T soundio/libsoundio
	cp -r "$srcdir/SDL_GameControllerDB-$_sdl_gamecontrollerdb_commit" \
		-T app/SDL_GameControllerDB

	default_prepare
}

build() {
	qmake6 PREFIX=/usr moonlight-qt.pro
	make
}

package() {
	make INSTALL_ROOT="$pkgdir" install
}

sha512sums="
4b3ca68e37083a9cc1d2f6c580911f4dcad2e2f59b9bf24b994ef760611e033a9a181fd78ef6fe95126094688d2d8169197bc6822edf8770d0af4809e7a40172  moonlight-qt-5.0.1.tar.gz
cb467592ef8fb7e45d38e691d9e762111d68c18e89975b3b37bc509373ecb1d382e2a3b6f8aa45774a65ba1bbd08a55adf6123f4428457867c8455544208c82e  h264bitstream-34f3c58afa3c47b6cf0a49308a68cbf89c5e0bff.tar.gz
9b8b7782d83c487165205bbd9051dcc2b9dc1a648d86b4e06ff3968d12cafbebafedd6ffe8e9b7e7adcae9e3e5da069e4e0322556e1b4f233b3979c50b6ac5c1  moonlight-common-c-5de4a5b85a28d8d639482a1a105c3a06eb67a2fd.tar.gz
0c3440982203b4eb71ff750992ec1cd8e56870d9179cc99447699c4a2691a0f656a31e862d89a53858f07041b832841898a35b14c3998d7b50ee825a6f43b4a2  enet-bbfe93c248ce198246328d52bda5b4e6dd4cc95e.tar.gz
49a857698f44baad8c539a0b889f4c0bf1b3af8f770fba4d6ea41ed145b825a81ed7a7e78813f66e3ccbf887612dba6988ffea2fcf7f016bad0fbebfc29705a4  qmdnsengine-b7a5a9f225d5e14b39f9fd1f905c4f505cf2ee99.tar.gz
946bd120eed3ffeb016dc6a7d6d29faf4006fb7a07ca7941b18a16fb7428307035a738da191016969287a544be6c98747802bb0b846f1ae03b24303b527ae415  libsoundio-34bbab80bd4034ba5080921b6ba6d61314126310.tar.gz
bceaf6f2c3c5ba8c6d0c65947056bd451e8dbf1edea0528d6faad8891a9fc37f41deb93fa00dd8b13ae406d6dda132f4e0bf87688f2473e67cb39412e82d1993  sdl-gamecontrollerdb-dbcf31a6709ec8354b5963b1bb411721e07bd846.tar.gz
1239544bb35fcbc457bf93b2e0a92d5389cea5da528da1dbb67e66e854131db3ff29e432e8e23c1ee3162a7bb84ecb15c34513814dea2a23d3cfd45b594acb20  0001-Fix-building-with-directfb.patch
"
